#include<bits/stdc++.h>
#define eps 1e-9
#define N 100005
#define ll long long
using namespace std;

pair<int,int>b[N];
int n,m,len,lim,d[N],v[N],a[N],p[N],c,k;

void sol()
{
    scanf("%d%d%d%d",&n,&m,&len,&lim);
    for(int i=1;i<=n;i++) scanf("%d%d%d",&d[i],&v[i],&a[i]);
    for(int i=1;i<=m;i++) scanf("%d",&p[i]);
    c=0;
    // k++;
    for(int i=1;i<=n;i++)
    {
        if(!a[i])
        {
            if(v[i]>lim)
            {
                int l=lower_bound(p+1,p+m+1,d[i])-p,r=m;
                if(l<m+1) b[++c]={l,r};
            }
            continue;
        }
        if(a[i]<0)
        {
            if(v[i]>lim)
            {
                int t=(lim*lim-v[i]*v[i])/(a[i]*2);
                if((lim*lim-v[i]*v[i])%(a[i]*2)==0) t--;
                // if(t<=0) continue;
                int l=lower_bound(p+1,p+m+1,d[i])-p,r=upper_bound(p+1,p+m+1,d[i]+t)-p-1;
                // cerr<<"D: "<<i<<' '<<t<<' '<<l<<','<<r<<endl;
                if(r==m+1) r=m;
                if(l<m+1&&l<=r) b[++c]={l,r};
            }
            continue;
        }
        if(v[i]>=lim)
        {
            int l=lower_bound(p+1,p+m+1,d[i]+(v[i]==lim))-p,r=m;
            if(l<m+1) b[++c]={l,r};
            continue;
        }
        int t=(lim*lim-v[i]*v[i]+a[i]*2-1)/(a[i]*2);
        if((lim*lim-v[i]*v[i])%(a[i]*2)==0) t++;
        int l=lower_bound(p+1,p+m+1,d[i]+t)-p,r=m;
        // if(k==14) cerr<<"D: "<<i<<' '<<t<<' '<<l<<','<<r<<endl;
        if(l<m+1) b[++c]={l,r};
    }
    // for(int i=1;i<=c;i++)cerr<<b[i].first<<','<<b[i].second<<endl;
    printf("%d ",c);
    if(!c)
    {
        printf("%d\n",m);
        return;
    }
    sort(b+1,b+c+1);
    int l=b[1].first,r=b[1].second,ans=0;
    for(int i=2;i<=c;i++)
    {
        if(b[i].first>r||b[i].second<l)
        {
            ans++;
            l=b[i].first;
            r=b[i].second;
        }
        else l=max(l,b[i].first),r=min(r,b[i].second);
    }
    // if(k==14)cerr<<n<<' '<<m<<' '<<len<<' '<<lim<<endl;
    printf("%d\n",m-ans-1);
}

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    scanf("%d",&t);
    // t=1;
    while(t--) sol();
    return 0;
}
// Code by Jorisy. Best Wishes & Good Luck.